(function (factory) {
    if (typeof module === "object" && typeof module.exports === "object") {
        var v = factory(require, exports);
        if (v !== undefined) module.exports = v;
    }
    else if (typeof define === "function" && define.amd) {
        define(["require", "exports", "react", "maishu-ui-toolkit", "json!websiteConfig"], factory);
    }
})(function (require, exports) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    const React = require("react");
    const ui = require("maishu-ui-toolkit");
    const json_websiteConfig_1 = require("json!websiteConfig");
    const imageThumbSize = 112;
    requirejs({ context: json_websiteConfig_1.contextName }, ['less!controls/image-thumber']);
    class ImageThumber extends React.Component {
        constructor(props) {
            super(props);
            this.state = { selectedText: '' };
        }
        setDeleteButton(e, imagePath) {
            if (!e)
                return;
            ui.buttonOnClick(e, (e) => {
                e.stopPropagation();
                e.cancelBubble = true;
                return this.props.remove(imagePath);
            }, {
                confirm: '确定删除该图片吗？'
            });
        }
        render() {
            let { imagePath, className, onClick, selectedText, text, title, disabled } = this.props;
            className = className || '';
            text = text || '';
            return (React.createElement("div", { className: `image-thumber ${className}`, title: title, "data-url": imagePath, onClick: (e) => {
                    if (disabled)
                        return;
                    this.props.onClick ? this.props.onClick(this, e) : null;
                } },
                React.createElement("div", { className: `item text-center  ${selectedText ? 'selected' : ''}` },
                    React.createElement("div", { className: "triangle" }),
                    React.createElement("div", { className: "top" }, selectedText),
                    this.props.remove ?
                        React.createElement("div", { className: "remove" },
                            React.createElement("i", { className: "icon-remove", ref: (e) => this.setDeleteButton(e, imagePath) })) : null,
                    React.createElement("img", { src: imagePath, ref: (e) => e ? ui.renderImage(e, { imageSize: { width: 150, height: 150 } }) : null }),
                    React.createElement("div", { className: "bottom" }, text),
                    disabled ? React.createElement("div", { className: "disabled" }) : null)));
        }
    }
    exports.default = ImageThumber;
});
